setwd("D:/1大学生活/大三下/zxy/R语言")
load("volcano.RData")

#加载所需库
library(clusterProfiler)
library(org.Hs.eg.db)

#设置数据库
GO_database = 'org.Hs.eg.db' 

#GO富集分析
#默认pvalueCutoff = 0.05，keyType为基因名(symbol)
GO = enrichGO(gene = prostat$ID[prostat$P<0.05], 
              OrgDb = GO_database, 
              keyType = "SYMBOL", 
              ont = "ALL", 
              readable = T)

#将GO结果转为数据框
GO_frame = data.frame(GO) 

#GO结果可视化，存为气泡图
pdf("data_dotplot.pdf", h = 8, w = 8)
dotplot(GO,  color = "pvalue", showCategory = 30,font.size = 6)
dev.off()
